/// FileName result_api_model
///
/// @Author lax
/// @Date 2023/3/1
///
/// @Description cosmic普通接口

class ResultApiModel<T> {
  int? code;
  int? dataCode;
  bool status;
  String? message;
  T? result;

  bool get success {
    return result != null;
  }

  ResultApiModel({
    this.code,
    this.dataCode,
    this.status = true,
    this.result,
    this.message,
  });

  factory ResultApiModel.fromJson(
      Map<String, dynamic> json, T Function(dynamic json)? fromJsonT) {
    int code = json['Code'] ?? 0;
    return ResultApiModel<T>(
      code: code,
      dataCode: json['DataCode'],
      status: json['Status'] ?? (code == 200),
      message: json['Message'] ?? '',
      result: (fromJsonT != null && json['Result'] != null)
          ? fromJsonT(json['Result'])
          : json['Result'],
    );
  }
}
